<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<form *ngIf="!!generalForm" [formGroup]="generalForm" autocomplete="off" gioFormFocusInvalid>
  <!-- Name -->
  <div class="card__endpoint-group-name">
    <mat-form-field class="card__endpoint-group-name__form-field">
      <mat-label>Name</mat-label>
      <input type="text" aria-label="Endpoints group name input" matInput formControlName="name" required />
      <mat-error *ngIf="generalForm.get('name').hasError('required')"> Name is required. </mat-error>
      <mat-error *ngIf="generalForm.get('name').hasError('pattern')">
        The endpoint group name does not support <code>:</code> in its name.
      </mat-error>
      <mat-error *ngIf="generalForm.get('name').hasError('isUnique')"> This name is used by another endpoint or endpoint group. </mat-error>
    </mat-form-field>
  </div>

  <!-- Load balancing algorithm -->
  <div class="card__endpoint-group-lb">
    <p class="card__endpoint-group-lb__hint">
      You can configure load balancing by creating a logical group of endpoints and specifying a load balancing algorithm for them.
    </p>
    <mat-form-field class="card__endpoint-group-lb__form-field">
      <mat-label>Load balancing algorithm</mat-label>
      <mat-select aria-label="Load balancing algorithm" formControlName="loadBalancerType" required>
        <mat-option *ngFor="let loadBalancerType of loadBalancerTypes" [value]="loadBalancerType">{{ loadBalancerType }}</mat-option>
      </mat-select>
      <mat-error *ngIf="generalForm.get('loadBalancerType').hasError('required')"> Load balancing algorithm is required. </mat-error>
    </mat-form-field>
  </div>
</form>
